import {
  IGetDecisionFlowGetRes,
  IPostDecisionFlowAddGraphReq,
  postDecisionFlowAddGraph,
  postDecisionFlowDelete,
  // postDecisionFlowPublish
  postDecisionFlowAudit,
  getDecisionFlowGet
} from '@/api';
import { MciButton, MciMessageBox, MciNotification, MciSvgIcon, MciTooltip } from '@/components/base';
import { NODE_TYPE } from '@/constants/config';
import { useGraph } from '@/hooks/useGraph';
import { useNodeResults } from '@/store/node-results';
import { TverificationItem, useNodeVerification } from '@/store/node-verification';
import { fetchOfSSE } from '@/utils/fetch';
import { showNodeStatusWithState, showNodeStatusWithVerification } from '@/utils/graph';
import { Action, ElMessageBox } from 'element-plus';
import type { PropType } from 'vue';
import { TestForm } from '../TestForm';
import { ApproveDetail } from '../ApproveDetail';
import { validateAssignments, validateConditions } from '@/utils/validator';
import { ACTION_TYPE } from '@/components/business/NodeAutomaticForm/components/AutomaticForm/data';
import { formatConditions } from '@/utils/edge-process';
import { DesignMore } from '../DesignMore';
import FileSaver from 'file-saver';
import { DATA_LOAD_TYPE } from '@/components/business/Nodes/DataLoad/components/DataSet/data';

export const FlowOperation = defineComponent({
  props: {
    flowDetail: {
      type: Object as PropType<IGetDecisionFlowGetRes>,
      default: () => ({})
    },
    permissionRoles: {
      type: Object,
      default: () => {}
    }
  },
  emits: ['delete', 'refresh'],
  setup(props, { emit }) {
    const execResultsStore = useNodeResults();
    const verificationStore = useNodeVerification();
    const statusLoading = ref(false);
    const flowDetail = ref<IGetDecisionFlowGetRes>(props.flowDetail);

    const { graph } = useGraph();
    const loading = ref(false);
    const loadingSave = ref(false);
    const loadingExport = ref(false);
    // const loading = ref(false);
    const route = useRoute();
    const flowId = computed(() => {
      return route.query.flowId as string;
    });
    const openApprove = ref(false);
    const approveParams = ref<object>({});
    const dialogVisible = ref(false);
    const router = useRouter();

    watchEffect(() => {
      flowDetail.value = props.flowDetail;
    });

    // const submitHandle = () => {
    //   saveHandle(false);
    // };

    const exportHandle = async () => {
      loadingExport.value = true;
      await getDecisionFlowGet({ flowId: flowId.value })
        .then((res) => {
          if (res) {
            const blob = new Blob([JSON.stringify(res, null, 2)], { type: 'application/json' });
            FileSaver.saveAs(blob, `${props.flowDetail.flowName}`);
          }
        })
        .finally(() => {
          loadingExport.value = false;
        });
    };

    // valid: 是否有效？0：代表临时保存，保存后还不能执行，因为没有校验，1：有效，代表提交，会进行校验
    const saveHandle = async (onlySave = true, isTest?: boolean) => {
      verificationStore.isExecuting = false;
      resetNodeStatus();
      verificationStore.clearResults();
      loadingSave.value = true;
      const data = graph.value?.toJSON();
      if (!data) return;

      const lines = graph.value?.getEdges().map((edge) => {
        const info = {
          fromNodeId: edge.getSourceCell()!.id as unknown as string,
          toNodeId: edge.getTargetCell()!.id as unknown as string,
          lineId: edge.id
        } as IPostDecisionFlowAddGraphReq['lines'][0];

        const condition = edge.getData().condition;
        if (condition) {
          const filteredConditions = formatConditionsParams(condition);
          info.conditions = filteredConditions;
        }
        if (info.conditions && Object.keys(info.conditions).length === 0) {
          delete info.conditions;
        }
        if (info.conditions) {
          const conjsList = condition[0]?.conditions?.conjs || [];
          const maxLength = info.conditions?.length;
          info.conditions.conjs = conjsList.slice(0, maxLength);
        }
        return info;
      });

      const nodes =
        graph.value?.getNodes().map((node) => {
          const nodeType = node.shape as keyof typeof NODE_TYPE;
          const nodeData = node.toJSON()?.data;
          const nodeName = nodeData.nodeName || nodeType;
          const nodePayload = nodeData.payload || {};
          const nodeId = node.id as unknown as string;
          const variables = nodeData.variables || [];
          const info = {
            nodeId,
            nodeName,
            nodeType
          } as Required<IPostDecisionFlowAddGraphReq['nodes'][0]>;

          if (['MODEL'].includes(nodeType)) {
            info.actionId = nodeData.actionId;
          } else if (nodeType === 'DATA_LOAD') {
            if (nodeData.dataLoad?.cfgType === DATA_LOAD_TYPE.EDIT) {
              const dataCfgReq = {
                cfgType: nodeData.dataLoad?.cfgType,
                tableName: nodeData.dataLoad?.dataSet?.tableName,
                columns: nodeData.dataLoad?.dataSet?.columns,
                conditions: nodeData.dataLoad?.dataSet?.conditions
              };
              info.dataCfgReq = dataCfgReq;
            } else {
              info.actionId = nodeData.actionId;
              info.dataCfgReq = {
                cfgType: DATA_LOAD_TYPE.CHOOSE
              };
            }
          } else if (nodeType === 'RULE') {
            info.ruleSetConfig = nodeData.conditionSetConfig;
            info.rules = nodeData.condition || [];
            // if (nodeData.condition) {
            //   const filteredConditions = formatConditionsParams(nodeData.condition);
            //   info.rules[0].conditions = filteredConditions;
            // }
            // if (info.rules[0].conditions && Object.keys(info.rules[0].conditions).length === 0) {
            //   delete info.rules[0].conditions;
            // }
            // const conjsList = nodeData.condition[0]?.conjs || [];
            // const maxLength = info.rules[0].conditions?.length;
            // info.rules[0].conjs = conjsList.slice(0, maxLength);
            info.rules?.map?.((item, index) => {
              item.ruleName = index + 1 + '';
            });
          } else if (nodeType === 'DATA_MODIFY') {
            if (nodeData.autoData && nodeData.autoData.cfgType === ACTION_TYPE.INSERT) {
              delete nodeData.autoData.conditions;
            }
            info.dataModifyCfgVO = nodeData.autoData;
          } else if (nodeType === 'FEATURE') {
            info.features = nodeData.featureData;
          }

          if (variables?.length) {
            info.variables = variables;
          }

          if (Object.keys(nodePayload)?.length) {
            info.payload = nodePayload;
          }
          return info;
        }) || [];

      const resolveFinalGraphJson = () => {
        const json = graph.value?.toJSON();
        if (json) {
          json.cells.map((item) => {
            if (item.shape === 'base-edge') {
              item.attrs = { line: { strokeDasharray: '', style: { animation: '' } } };
            } else if (item.view === 'vue-shape-view') {
              delete item.data.status;
            }
          });
        }
        return json;
      };

      const newGraph = JSON.stringify(resolveFinalGraphJson());
      try {
        await postDecisionFlowAddGraph({
          flowId: flowId.value,
          graph: newGraph,
          valid: onlySave ? 0 : 1,
          nodes,
          lines
        });

        if (!isTest) {
          MciNotification.success({
            message: onlySave ? '保存成功' : '提交成功',
            position: 'bottom-right'
          });
        }
      } finally {
        loadingSave.value = false;
      }
    };

    // 过滤掉规则中 conditions中空数组或仅包含空对象
    const formatConditionsParams = (nodeVariables: any) => {
      let infoConditions = {};
      // 过滤掉 conditions.conditions 数组中为空的对象
      const conditions = nodeVariables[0]?.conditions || [];
      const filteredConditions = conditions.conditions?.filter((condition) => Object.keys(condition).length !== 0);
      // 只有当 conditions.conditions 有非空对象时，才添加到 info.conditions
      if (filteredConditions?.length) {
        infoConditions = {
          ...conditions,
          conditions: filteredConditions
        };
      }
      return infoConditions;
    };

    const testHandle = async () => {
      const validResult = validateHandle();
      if (!validResult) {
        return;
      }
      verificationStore.isExecuting = false;
      resetNodeStatus();
      verificationStore.clearResults();
      try {
        if (flowDetail.value.status === 0) {
          await saveHandle(false, true);
        }
        dialogVisible.value = true;
      } catch (error) {
        console.log(error);
      }
    };

    const deleteFlow = () => {
      MciMessageBox.confirm('是否确定删除该版本？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        postDecisionFlowDelete({ flowId: flowId.value }).then(() => {
          MciNotification.success({
            title: '操作成功'
          });
          emit('delete');
          router.push({ name: 'DecisionFlow' });
        });
      });
    };

    const resetNodeStatus = () => {
      graph.value?.getEdges().forEach((edge) => {
        // 将edge的颜色改为默认未执行颜色
        edge.attr({
          line: {
            stroke: '#A2B1C3',
            strokeDasharray: 0,
            strokeWidth: 1.1,
            style: {
              animation: ''
            }
          }
        });
        // 将edge的label改为默认未执行的颜色
        const condition = edge.getData().condition;
        const strList: string[] = [];
        if (condition) {
          if (typeof condition === 'string') {
            // 如果condition是字符串，将其转换为数组
            const assignment = { conditions: { conditions: condition, conjs: [] } };
            const formattedConditions = formatConditions(assignment.conditions.conditions, assignment.conditions.conjs);
            formattedConditions && strList.push(formattedConditions);
          } else if (Array.isArray(condition)) {
            // 如果condition是数组，则直接进行处理
            condition.forEach((assignment) => {
              const formattedConditions = formatConditions(assignment.conditions.conditions, assignment.conditions.conjs);
              formattedConditions && strList.push(formattedConditions);
            });
          }
        }
        if (strList && strList.length) {
          edge?.setLabels([
            {
              attrs: {
                label: { text: strList.join('\n\n') },
                text: {
                  fill: 'var(--color-blue-6)',
                  fontSize: 12,
                  textAnchor: 'middle',
                  textVerticalAnchor: 'middle'
                },
                rect: {
                  ref: 'label',
                  fill: 'var(--color-blue-1)',
                  stroke: 'var(--color-blue-4)',
                  refWidth: 14,
                  refHeight: 5,
                  refX: -7,
                  refY: -2.5,
                  rx: 20,
                  ry: 20
                }
              },
              position: {
                distance: 0.5
              }
            }
          ]);
        } else {
          edge.setLabels([]);
        }
      });

      // 重置节点state
      graph.value?.getNodes().map((node) => {
        node.getData().setNodeData({
          status: ''
        });
      });
    };

    const execFinish = () => {
      verificationStore.isExecuting = false;
      execResultsStore.isExecuting = false;
      resetNodeStatus();
      execResultsStore.clearResults();
      verificationStore.clearResults();
    };

    // const enableChange = async () => {
    //   const changeEnable = () => {
    //     enableLoading.value = true;
    //     const enable = flowDetail.value.enable ? 0 : 1;
    //     postDecisionFlowEnable({ flowId: flowId.value, enable: String(enable) })
    //       .then(() => {
    //         flowDetail.value.enable = enable;
    //         MciNotification.success({
    //           message: flowDetail.value.enable ? '启用成功' : '禁用成功',
    //           position: 'bottom-right'
    //         });
    //       })
    //       .finally(() => {
    //         enableLoading.value = false;
    //       });
    //   };

    //   if (flowDetail.value.enable === 1) {
    //     ElMessageBox.alert('是否确定停用已启用的决策流？停用后业务系统调用决策流将返回决策流已停用异常。', '提示', {
    //       confirmButtonText: '确定',
    //       callback(action: Action) {
    //         if (action === 'confirm') {
    //           changeEnable();
    //         }
    //       }
    //     });

    //     return;
    //   }

    //   changeEnable();
    // };

    // 点击状态按钮回调
    const statusChange = async () => {
      statusLoading.value = true;
      if (flowDetail.value.status === 0) {
        ElMessageBox.alert('是否确定将决策流提交审批？', '提示', {
          confirmButtonText: '确定',
          callback(action: Action) {
            if (action === 'confirm') {
              // postDecisionFlowPublish({ flowId: flowId.value })//这个接口逻辑调整为给全流程调用
              postDecisionFlowAudit({ flowId: flowId.value })
                .then(() => {
                  MciNotification.success({
                    title: '提交成功'
                  });
                  emit('refresh');
                })
                .finally(() => {
                  statusLoading.value = false;
                });
            } else {
              statusLoading.value = false;
            }
          }
        });
        return;
      } else if (flowDetail.value.status === 1 || flowDetail.value.status === 2) {
        openApprove.value = true;
        statusLoading.value = false;
        approveParams.value = {
          status: flowDetail.value.status,
          flowId: flowId.value
        };
        return;
      }
    };

    // flowDetail.value.status为0，即初始状态得时候是保存测试，其他时候都只是测试，不保存
    const executeHandle = async (testParams: Record<string, any>) => {
      try {
        verificationStore.isExecuting = false;
        resetNodeStatus();
        verificationStore.clearResults();
        execResultsStore.clearResults();
        execResultsStore.isExecuting = true;
        loading.value = true;

        // if(flowDetail.value.status === 0) {
        //   await saveHandle(false, true);
        // }
        // if (!onlyTest) {
        //   await saveHandle(false, true);
        // }

        fetchOfSSE('/decision-flow/test', {
          method: 'POST',
          body: JSON.stringify({ flowId: flowId.value, param: testParams }),
          headers: {
            'Content-Type': 'application/json'
          },
          onMessage(message) {
            if (message === '[DONE]') {
              MciNotification.success({
                message: '测试执行完成',
                position: 'bottom-right'
              });
              loading.value = false;
              execResultsStore.isExecuting = false;
              graph.value?.getNodes().map((node) => {
                const hasResult = execResultsStore.resultsOfList.some((item) => {
                  return item.nodeId === node.id;
                });

                if (!hasResult) {
                  node.getData().setNodeData({
                    status: ''
                  });
                }
              });

              graph.value?.getEdges().map((edge) => {
                const hasResult = execResultsStore.resultsOfList.some((item) => {
                  return item.lineId === edge.id;
                });

                if (!hasResult) {
                  edge.attr({
                    line: {
                      stroke: '#A2B1C3',
                      strokeDasharray: 0,
                      strokeWidth: 1.1,
                      style: {
                        animation: ''
                      }
                    }
                  });
                }
              });
              return;
            }
            try {
              const data = JSON.parse(message);
              execResultsStore.addResults(data);
              showNodeStatusWithState(graph.value!, data);
            } catch (err) {
              console.error(err);
              return;
            }
          }
        });
        loading.value = false;
      } catch (err) {
        resetNodeStatus();
        execResultsStore.isExecuting = false;
      } finally {
        loading.value = false;
      }
    };
    // 校验决策
    const validateHandle = () => {
      let validResult = true;
      try {
        execResultsStore.clearResults();
        execResultsStore.isExecuting = false;

        verificationStore.clearResults();
        verificationStore.isExecuting = true;

        loading.value = true;
        const data = graph.value?.toJSON();
        if (!data) return;
        // 连线校验
        graph.value?.getEdges().forEach((edge) => {
          let validateItem = {
            fromNodeId: edge.getSourceCell()!.id as unknown as string,
            toNodeId: edge.getTargetCell()!.id as unknown as string,
            lineId: edge.id,
            errorMsg: [],
            execStatus: 'PASS'
          } as IPostDecisionFlowAddGraphReq['lines'][0];

          const lineConditions = edge.getData().condition;
          if (lineConditions && lineConditions.length) {
            for (let index = 0; index < lineConditions.length; index++) {
              const element = lineConditions[index];
              if (element) {
                const conditions = element.conditions;
                if (conditions) {
                  validateItem.errorMsg = validateItem.errorMsg.concat(
                    validateConditions(conditions, `第${index + 1}个条件配置`)
                  );
                }
              }
            }
          }
          if (validateItem.errorMsg && validateItem.errorMsg.length > 0) {
            validateItem.execStatus = 'REJECT';
            validResult = false;
          }

          try {
            verificationStore.addResults(validateItem);
            showNodeStatusWithVerification(graph.value!, validateItem, false);
          } catch (err) {
            console.error(err);
            return;
          }
        });
        // 节点校验
        graph.value?.getNodes().forEach((node) => {
          const nodeType = node.shape as keyof typeof NODE_TYPE;
          const nodeData = node.toJSON()?.data;
          const nodeId = node.id as unknown as string;
          const nodeName = nodeData.nodeName || nodeType;
          let validateItem: TverificationItem = {
            nodeId,
            nodeName,
            nodeType,
            errorMsg: [],
            execStatus: 'PASS'
          };
          validateItem.nodeId = nodeId;

          switch (nodeType) {
            case 'DATA_LOAD':
              if (nodeData.dataLoad?.cfgType === DATA_LOAD_TYPE.EDIT) {
                // tableName: nodeData.dataLoad?.dataSet?.tableName,
                // columns: nodeData.dataLoad?.dataSet?.columns,
                // conditions: nodeData.dataLoad?.dataSet?.conditions
                if (!nodeData.dataLoad?.dataSet?.tableName) {
                  validateItem.errorMsg.push('数据集不可为空');
                }
                if (!nodeData.dataLoad?.dataSet?.columns || !nodeData.dataLoad?.dataSet?.columns.length) {
                  validateItem.errorMsg.push('查询列不可为空');
                }
                if (
                  !nodeData.dataLoad?.dataSet?.conditions ||
                  !nodeData.dataLoad?.dataSet?.conditions.conditions ||
                  !nodeData.dataLoad?.dataSet?.conditions.conditions.length
                ) {
                  validateItem.errorMsg.push('条件不可为空');
                }
              } else if (nodeData.dataLoad?.cfgType === DATA_LOAD_TYPE.CHOOSE) {
                if (!nodeData.actionId) {
                  validateItem.errorMsg.push('数据加载不可为空');
                }
              }
              break;
            case 'MODEL':
              if (!nodeData.actionId) {
                validateItem.errorMsg.push('模型不可为空');
              }
              break;
            case 'RULE':
              const rules = nodeData.condition;
              if (!rules) {
                validateItem.errorMsg.push('规则赋值不可为空');
              } else {
                for (let index = 0; index < rules.length; index++) {
                  const ruleItem = rules[index];
                  if (ruleItem) {
                    const conditions = ruleItem.conditions;
                    const assignments = ruleItem.assignments;
                    if (!conditions) {
                      const msg = `第${index + 1}个规则赋值的条件配置不可为空`;
                      validateItem.errorMsg.push(msg);
                    } else {
                      validateItem.errorMsg = validateItem.errorMsg.concat(
                        validateConditions(conditions, `第${index + 1}个规则赋值`)
                      );
                    }
                    if (assignments) {
                      validateItem.errorMsg = validateItem.errorMsg.concat(
                        validateAssignments(assignments, `第${index + 1}个规则赋值`)
                      );
                    }
                  }
                }
              }

              break;
            case 'DATA_MODIFY':
              if (!nodeData.autoData) {
                validateItem.errorMsg.push('自动处理节点不可为空');
              } else if (!nodeData.autoData.tableName) {
                validateItem.errorMsg.push('节点设置：数据集不可为空');
              } else if (!nodeData.autoData.mapping) {
                validateItem.errorMsg.push('节点设置：参数映射不可为空');
              } else {
                const keys = Object.keys(nodeData.autoData.mapping);
                if (!keys || !keys.length) {
                  validateItem.errorMsg.push('节点设置：参数映射不可为空');
                }
                if (nodeData.autoData.cfgType === ACTION_TYPE.UPDATE) {
                  validateItem.errorMsg = validateItem.errorMsg.concat(
                    validateConditions(nodeData.autoData.conditions, '更新记录key')
                  );
                }
              }
              break;
            case 'FEATURE':
              if (!nodeData.featureData || !nodeData.featureData.length) {
                validateItem.errorMsg.push('特征节点不可为空');
              } else {
                for (let i = 0; i < nodeData.featureData.length; i++) {
                  const feature = nodeData.featureData[i];
                  if (!feature) {
                    const desc = `第${i + 1}个特征函数不可为空`;
                    validateItem.errorMsg.push(desc);
                  }
                }
              }
              break;
            default:
              break;
          }
          if (validateItem.errorMsg && validateItem.errorMsg.length > 0) {
            validateItem.execStatus = 'REJECT';
            validResult = false;
          }

          try {
            verificationStore.addResults(validateItem);
            showNodeStatusWithVerification(graph.value!, validateItem);
          } catch (err) {
            console.error(err);
            return;
          }
        });

        loading.value = false;
      } catch (err) {
        resetNodeStatus();
        execResultsStore.isExecuting = false;
      } finally {
        loading.value = false;
      }
      return validResult;
    };

    const statusTitle = (status: number) => {
      switch (status) {
        case 0:
          return '提交审批';
        case 1:
          return '审核中';
        case 2:
          return '已发布';
        case 3:
          return '已下线';
        default:
          break;
      }
    };

    watch(
      flowId,
      () => {
        resetNodeStatus();
        execResultsStore.clearResults();
      },
      { immediate: true }
    );

    return () => (
      <div class="flex items-center flow-operation">
        <div class="pr-16 flex items-center gap-2">
          {props.permissionRoles?.configRole && props.flowDetail.status === 0 && (
            <div class="pr-12 flow-delete">
              <a onClick={deleteFlow} href="javascript:;" class="cr-red-4 font-bold">
                删除版本
              </a>
            </div>
          )}
          {!execResultsStore.hasExecResult && (
            <div class="pr-12 flex items-center gap-4 flow-enable">
              {(props.permissionRoles?.checkRole || props.permissionRoles?.approveRole || props.permissionRoles?.configRole) &&
                props.flowDetail.status !== 0 && (
                  <MciButton
                    type="primary"
                    disabled={props.flowDetail.status === 3}
                    loading={statusLoading.value}
                    onClick={statusChange}>
                    <span>{statusTitle(props.flowDetail.status)}</span>
                  </MciButton>
                )}
              {/* 当用户为审批岗且状态为0时，展示提交审批按钮 */}
              {props.flowDetail.status === 0 && props.permissionRoles?.configRole && (
                <MciButton type="primary" loading={statusLoading.value} onClick={statusChange}>
                  <MciTooltip content="提交审批前请确保执行测试通过">
                    <MciSvgIcon width={16} height={16} name="info" class="cursor-pointer" color="#FFFFFF" />
                  </MciTooltip>
                  <span class="ml-8">提交审批</span>
                </MciButton>
              )}
            </div>
          )}
          <MciButton loading={loading.value} type="info" onClick={testHandle}>
            <MciSvgIcon width={18} height={18} color="var(--color-grey-5)" name="play" />
            <span class="ml-8">测试</span>
          </MciButton>
          {!execResultsStore.hasExecResult ? (
            <>
              {props.permissionRoles?.configRole && (
                <MciButton
                  type="info"
                  onClick={() => {
                    const url = router.resolve({ name: 'DocCreate', query: { flowId: flowId.value } }).href;
                    window.open(url, '_blank');
                  }}>
                  <MciSvgIcon width={18} height={18} color="var(--color-grey-5)" name="doc" />
                  <span class="ml-8">生成文档</span>
                </MciButton>
              )}
              {props.flowDetail.status === 0 && props.permissionRoles?.configRole && (
                <>
                  <MciButton loading={loadingSave.value} type="info" onClick={saveHandle}>
                    <MciSvgIcon width={18} height={18} color="var(--color-grey-5)" name="save" />
                    <span class="ml-8">保存</span>
                  </MciButton>
                </>
              )}
              {props.flowDetail.status !== 0 || !props.permissionRoles?.configRole ? (
                <>
                  <MciButton loading={loadingExport.value} type="info" onClick={exportHandle}>
                    <MciSvgIcon width={18} height={18} color="var(--color-grey-5)" name="export" />
                    <span class="ml-8">导出</span>
                  </MciButton>
                </>
              ) : (
                <DesignMore
                  flowId={flowId.value}
                  decisionId={props.flowDetail.decisionId}
                  categoryId={props.flowDetail.categoryId}
                  flowName={props.flowDetail.flowName}
                />
              )}
            </>
          ) : (
            <MciButton loading={loading.value} type="primary" onClick={execFinish}>
              测试完成
            </MciButton>
          )}
        </div>

        {dialogVisible.value && (
          <TestForm
            flowId={flowId.value}
            flowValid={flowDetail.value.valid}
            onFormSubmit={executeHandle}
            onUpdate:modelValue={(val) => {
              dialogVisible.value = val;
            }}
          />
        )}

        <ApproveDetail
          v-model={openApprove.value}
          params={approveParams}
          flowId={flowId.value}
          flowStatus={flowDetail.value.status}
          onRefresh={() => {
            openApprove.value = false;
            emit('refresh');
          }}
        />
      </div>
    );
  }
});
function exportDecision(flowId: any, flowName: any) {
  throw new Error('Function not implemented.');
}
